package bert.viewer;

import java.awt.Dimension;
import java.io.InputStream;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import bert.SvgLoader;
import bert.TrackModel;
import bert.TrackSegment;

public class TrackModelViewer {

	public static void main(String[] args) {
		
		SwingUtilities.invokeLater(new Runnable() {
			@Override public void run() { createAndShowGUI(); }
		});
		
	}
	
	private static void createAndShowGUI() {
        assert SwingUtilities.isEventDispatchThread();
        
        JFrame f = new JFrame("Swing Paint Demo");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(new Dimension(960, 640));
        f.setVisible(true);
        
        ViewerComponent viewer = new ViewerComponent();
        
        f.add(viewer);
        f.pack();
        
        InputStream stream = getStream("/bert/test/polygon/track-non-linear.svg");        
        TrackModel trackModel = TrackSegment.CreateTrack(SvgLoader.ReadStream(stream));
        
        viewer.SetTrackModel(trackModel);
    }

	private static InputStream getStream(String name) {
		return TrackModelViewer.class.getResourceAsStream(name);
	}
}
